package com.itheima;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class CollectionsDemo {
    public static void main(String[] args) {
        List<String> list = new LinkedList<>();
        Collections.addAll(list, "a", "b", "c", "d");
        list.forEach(System.out::println);
        System.out.println("______________________________");

        // 打乱顺序
        Collections.shuffle(list);
        list.forEach(System.out::println);
        System.out.println("______________________________");
    }

    public static void test1() {
        List<Integer> list = new ArrayList<>();
        Collections.addAll(list, 1,2,3,4,5);
        //按照倒叙排序
        Collections.sort(list);
        list.forEach(System.out::println);
        Collections.sort(list,(o1, o2) ->{
                return o2 - o1;
        });
        System.out.println("______________________________");
        list.forEach(System.out::println);
        System.out.println("______________________________");
        //让学生Student实现Comparable接口，这样也能给学生排序
        List<Student> list1 = new ArrayList<>();
        list1.add(new Student("zs", 18));
        list1.add(new Student("zl", 19));
        list1.add(new Student("ww", 20));
        Collections.sort(list1);
        list1.forEach(System.out::println);

        List<Integer> synchronizedList = Collections.synchronizedList(list);


    }



}
